<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <style>
    * {
      margin: auto 0px;
      padding: 0px;
    }
    html,
    body {
      height: 100%;
      width: 100%;
    }
    #contaier {
      height: 100%;
      width: 100%;
      position: relative;
      background-color: aquamarine;
    }
    #panel1 {
      top: 10px;
      left: 20px;
      height: 300px;
      width: 500px;
      position: absolute;
      background-color: coral;
    }
  </style>
  <body>
    <div id="contaier">
      <div id="panel1"></div>
    </div>
    <script>
      var windowSize = {
        width: window.innerWidth,
        height: window.innerHeight,
      };
      var panel = document.getElementById("panel1");
      var panelSize = {
        width: panel.clientWidth,
        height: panel.clientHeight,
      };

      window.onresize = function () {
        console.log(window.innerHeight, window.innerWidth);
        var newWindowSize = {
          width: window.innerWidth,
          height: window.innerHeight,
        };

        var changePercent={
            width:newWindowSize.width/windowSize.width,
            height:newWindowSize.height/windowSize.height,
        }

        var newPanelSize={
            width:panelSize.width*changePercent.width,
            height:panelSize.height*changePercent.height
        }

        panel.style.height = newPanelSize.height+'px';
        panel.style.width=newPanelSize.width+'px';

      };
    </script>
  </body>
</html>
